package gc;

import lombok.extern.slf4j.Slf4j;

import java.util.Timer;
import java.util.TimerTask;

@Slf4j
public class TimerTest {

    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.schedule(new TimerTask(){
                int i = 0;
            @Override
            public void run() {
                try {
                    Thread.sleep(1000L);
                    new Thread(new Runnable() {
                        @Override
                        public void run() {
                            while(true){
                                try {
                                    Thread.sleep(100);
                                    ReferenceCountingGC referenceCountingGC = new ReferenceCountingGC();
                                    i++;
                                    log.info("i:{}",i);
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }

                        }
                    }).start();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
        },1000,1000);
    }
}
